//处理提交表单返回的数据
var successDealerCallback = function (data) {
    window.location.href = '/Home/DealerPage/index.html';
};
$(function () {  
    $('#login-container').inputValidate({
        submit: {
            query: '#requestSubmitDealer'
        },
        inputs: [{
            query: '#requestUsernameDealer',
            regexp: window.commonRegexp.mobile,
            message: lang('tip.mobile'),
            emptyMessage: lang('tip.mobileNull')
        }, {
            query: '#requestPasswordDealer',
            regexp: window.commonRegexp.password,
            message: lang('tip.password'),
            emptyMessage: lang('tip.passwordNull')
        }]
    });
    $('#requestSubmitDealer').on('successSubmit.amos.inputValidate', function (e) {
        var submitBtn = $(this);
        // 该处可放ajax请求
        submitBtn.attr('disabled', true);
        var params = {};
        params.mobile = $('#requestUsernameDealer').val();
        params.password = $('#requestPasswordDealer').val();
        params.areaCode = $('.areaCodeValue').text().trim();
        ajaxRequest('/Home/Dealer/login', params, 'post', successDealerCallback, function(data){
            $('#login-tip').html(data.responseJSON.info);
            $('#login-tip').closest('.form-group').addClass('has-error');
        }, submitBtn);
    });
});
